
/**
 * Created by Rex on 2017/3/6.
 */
package com.yzh.pinboard.BoardView;
import android.graphics.Bitmap;
import android.graphics.Matrix;

/**
 * Created by OCQIT500 on 2017/3/6.
 */

public class BitmapOperate {

    public static Bitmap getBitmap(Bitmap bitmap, int screenWidth, int screenHight) {
        int w = bitmap.getWidth();
        int h = bitmap.getHeight();
        Matrix matrix = new Matrix();
        float scale = (float) screenWidth / w;
        float scale2 = (float) screenHight / h;
        scale = scale < scale2 ? scale : scale2;
        matrix.postScale(scale, scale);
        Bitmap bmp = Bitmap.createBitmap(bitmap, 0, 0, w, h, matrix, true);
        return bmp;
    }

}
